Canonization of the Hebrew Bible discusses the history and formation of the Hebrew Bible.
Structure
The Hebrew Bible is arranged into the Law, the Prophets, and the Hagiographa (Sacred Writings, the Writings).
The Law comprises the Pentateuch. The Prophets comprise the Former Prophets (Joshua, Judges, Samuel, Kings) and the Latter Prophets (Isaiah, Jeremiah, Ezekiel, and the Book of the Twelve Prophets). The Writings contain Psalms, Proverbs, Job; the five Scrolls (Song of Songs, Ruth, Lamentations, Ecclesiastes, Esther); and Daniel, Ezra, Nehemiah, and Chronicles.
This grouping is referenced in Luke 24:44: Now He said to them, “These are My words which I spoke to you while I was still with you, that all the things that are written about Me in the Law of Moses and the Prophets and the Psalms must be fulfilled.”
The origin of the arrangement is unknown, but maybe it is based on literary character or the order in which they received canonical recognition.
The books are 24, but they can be made 22 when Ruth was appended to Judges and Lamentations to Jeremiah to match the length of the Hebrew alphabet.
(The Origin of the Bible: Newly Updated by F. F. Bruce, J. I. Packer, Philip W. Comfort, and Carl F. H. Henry, 2020. Biblical Languages by Larry Walker. Section One: The Authority and Inspiration of the Bible. Page 5-6; The Canon of the Old Testament by R. T. Beckwith. Page 56-61)
The Law (comprises the Pentateuch)
Ends with the genealogy of David
The Hagiographa, The Writings, Sacred Writings